/**
 * 
 */
var start = false;
var startX=0, startY=0;
var ctx;

function drawingInit(){
	document.getElementById('canvas').onmousemove=chk;
	document.getElementById('canvas').onmousedown=set;
	ctx = document.getElementById('canvas').getContext('2d');
}
function set(ev){
	start = !start;
	startX = ev.x;
	startY = ev.y;
	
	//선 그리기 시작점 설명
	if(start){  //선을 그리기 위한 시작점
		ctx.beginPath();
		ctx.moveTo(startX, startY);
		lc= document.getElementById("lineColor");
		lw=document.getElementById("lineWidth");
		ctx.strokeStyle=lc.value;
		ctx.lineWidth=lw.value;
	}else{  // 선을 마무리
		ctx.closePath();
	}
}
function chk(ev){
	var d = document.getElementById("result");
	var x = ev.x;
	var y = ev.y;
	d.innerHTML = 'x = ' + x + ', y = ' + y;
	if(start){
	ctx.lineTo(x,y);
	ctx.stroke();
	}
}